package com.example.tsbs.mapper;

import com.example.tsbs.entity.Task;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【task】的数据库操作Mapper
* @createDate 2024-03-06 15:10:17
* @Entity com.example.tsbs.entity.Task
*/
@Mapper
public interface TaskMapper extends BaseMapper<Task> {

    @Select("<script>select * from task " +
            "<where> " +
            "<if test=\"done != null and done != ''\"> and done like concat('%',#{done},'%') </if>" +
            "<if test=\"taskType != null and taskType != ''\"> and task_type like concat('%',#{taskType},'%') </if>" +
            "</where>" +
            "order by id desc</script>")
    List<Task> get(@Param("done") Integer done,@Param("taskType") String taskType);

    @Select("<script>select * from task " +
            "order by id desc</script>")
    List<Task> getAll();

//    @Insert("insert into task(type,progress,done,parameter,response) " +
//            "values (#{type},#{progress},#{done},#{parameter},#{response})")
//    int add(Task data);
//
//    @Delete("delete from task where id = #{id} ")
//    void deleting(@Param("id") Integer id);
//
    @Update("update task set progress=#{data.progress},done=#{data.done},response=#{data.response} " +
            "where id = #{id}")
    int updating(Task data,Integer id);
//
//    @Select("select * from task where task_name=#{name}")
//    Task getOneByName(@Param("name") String name);
//
//    @Select("select * from task where task_name=#{name} and order by id desc")
//    List<Task> getListOneByName(@Param("name") String name);

    @Select("select * from task where type=#{type} and order by id desc")
    List<Task> getListOneByType(@Param("type") String type);

    @Select("select * from task where id=#{id}")
    Task getById(@Param("id") Integer id);

}




